﻿using System.Collections.Generic;
using UnityEngine;

public enum EActionStatus
{
    Prepare,
    Running,
    Finish,
}

/// <summary>
/// 死亡动作
/// </summary>
public class DieAction : IAction
{
    private float time = 0;

    protected EActionStatus eActionStatus = EActionStatus.Prepare;

    public DieAction(OwnerObj ownerObj) : base(ownerObj)
    {
        eActionStatus = EActionStatus.Prepare;
    }

    public override void Interrupt()
    {
        throw new System.NotImplementedException();
    }

    public override bool IsCanInterrupt(IAction nextAction)
    {
        return false;
    }

    public override bool IsFinished()
    {
        // 死亡后不能切换其他啊动作
        return false;
    }

    public override void Load()
    {
        eActionStatus = EActionStatus.Running;

        ownerObj.Get<IUnitObject>().GetUnityGameObject().SetAnmiTrigger("Die");
    }

    public override void Unload()
    {
        
    }

    public override void Update(float deltaTime)
    {
        if (eActionStatus == EActionStatus.Running)
        {
            time += deltaTime;

            if (time > 1)
            {
                eActionStatus = EActionStatus.Finish;

                // 移除
                ownerObj.Get<IWorldObject>().Die();
            }
        }
    }
}